var page = {};

// -------- 模块引入区 --------

// -------- 事件管理区 --------
commonUtil.bindEventMap({
    '[role-action="提交反馈"]': _submit
});

// -------- 临时变量区 --------
var _refreshYjfkListEvent;

// -------- 函数方法区 --------
page.init = function(refreshYjfkListEvent) {
    _refreshYjfkListEvent = refreshYjfkListEvent;

    var html = `
        <form id="yjForm" style="margin-bottom:70px;"></form>

        <div class="footer_btn_container">
            <a href="javascript:void(0);" class="gs-btn gs-btn-danger" style="font-size:18px; width:100%; padding:16px;" role-action="提交反馈">提交</a>
        </div>

    `;
    zeroYddModal.show({
        title: '欢迎留下您的意见',
        content: html
    });

    var model = [{
        display: '分类',
        name: 'yjfl.FKFLGID',
        ztype: 'picker',
        dic: 'bjsx.yjfkfl',
        required: true
    }, {
        display: '反馈内容',
        name: 'yjfl.NR',
        required: true,
        ztype: 'textarea'
    }, {
        display: '是否匿名',
        name: 'yjfl.SFNM',
        ztype: 'switcher',
        dic: 'xbzd.sfbz',
        required: true
    }, {
        display: '手机',
        name: 'yjfl.SJ',
        placeholder: ''
    }, {
        display: '邮箱',
        name: 'yjfl.YX',
    }, {
        display: '上传图片',
        name: 'yjfl.FJBH',
        ztype: 'file-pic',
        placeholder: ''
    }];

    commonUtil.buildYddFormPage({
        model: model,
        cols: 1,
        formId: 'yjForm',
        callback: function() {}
    });
}

function _submit() {
    if (!$('#yjForm').validate().form()) {
        return;
    }

    commonUtil.confirm('确认提交意见反馈吗？', function() {
        var ydfkData = commonUtil.getFormValue('yjForm');
        ydfkData.picJson = commonUtil.getZeroObj('#yjForm [name="yjfl.FJBH"]').getValue();

        commonUtil.doAction(SYS_CONTROLLER_PATH + '/save', ydfkData, function() {
            zeroYddModal.closeAll();
            _refreshYjfkListEvent();
        });
    });
}


module.exports = page;